package query

import (
	"strings"

	"ssalarm/common/dto"
)

type SysDevVariableQuery struct {
	dto.Pagination `search:"-"`
	dto.OrderBy    `search:"-"`
	dto.UserInfo
	Sn     string `form:"sn"  search:"type:exact;column:sn;table:sys_dev_variable"`
	Sns    string `form:"sns" search:"-"`
	Keys   string `form:"keys" search:"-"`
	DeptId string `form:"deptId" search:"-"`
	Type   string `form:"type"  search:"type:exact;column:type;table:sys_dev_variable"`

	SnIn  []string `search:"type:in;column:sn;table:sys_dev_variable"`
	KeyIn []string `search:"type:in;column:key;table:sys_dev_variable"`
}

func (m *SysDevVariableQuery) GetNeedSearch() interface{} {
	if len(m.Sns) > 0 {
		m.SnIn = strings.Split(strings.ReplaceAll(m.Sns, " ", ""), ",")
	}
	if len(m.Keys) > 0 {
		m.KeyIn = strings.Split(strings.ReplaceAll(m.Keys, " ", ""), ",")
	}
	return *m
}
